package com.firesys.rounting.ui;

import com.firesys.R;
import com.firesys.dbhelper.SharedPreferenceUtil;
import com.firesys.dbhelper.XmlNameHelper;
import com.firesys.rounting.db.DeviceRoutingDao;


import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.PopupWindow;
import android.widget.LinearLayout.LayoutParams;

/**
 * 设备查询
 * @author Administrator
 *
 */
public class DeviceQueryActivity extends Activity{

	private View mPopView;//分类查询VIEW
	
	private DeviceRoutingDao  dao;
	
	private SharedPreferenceUtil  sp;
	
	private PopupWindow mPopupWindow;
	
	private String devicelistid;
	
	private View main;
	
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.device_list_query);
		main=LayoutInflater.from(this).inflate(R.layout.device_list_query, null);
		devicelistid=getIntent().getStringExtra("devicelistid");
		sp=new SharedPreferenceUtil(this);
		dao=new DeviceRoutingDao(this, sp.getValue(XmlNameHelper.SqliteName));
		mPopView = LayoutInflater.from(this).inflate(R.layout.device_list_popupwindow, null);
		

		
	}
	
	
	/**
	 * 初始化菜单
	 */
	private void initPopupWindow() {
		
		if (mPopupWindow == null) {
			mPopupWindow = new PopupWindow(mPopView, LayoutParams.FILL_PARENT,
					LayoutParams.WRAP_CONTENT, true);
			mPopupWindow.setBackgroundDrawable(new BitmapDrawable());
	
		}
		if (mPopupWindow.isShowing()) {
			mPopupWindow.dismiss();
		} else {
			mPopupWindow.showAsDropDown(main, 0, 150);
		}
	}

	public void btn_back(View v){
		Intent  intent=new Intent();
		intent.putExtra("devicelistid", devicelistid);
		setResult(RESULT_OK, intent);
	}
	
	public void btn_fenlei(View v){
		initPopupWindow();
	}
	
}
